﻿
namespace DAPNet
{
    public class Reverser : IOfflineEffect
    {
        internal Reverser()
        {
        }

        public void Process(SampleCollection samples)
        {
            int centerIndex = (samples.Count / 2);
            for (int i = 0; i < centerIndex; i++)
            {
                Sample sample1 = samples[i];
                Sample sample2 = samples[samples.Count - i];
                SwapSampleValues(sample1, sample2);
            }
        }

        private void SwapSampleValues(Sample sample1, Sample sample2)
        {
            double sample1Value = sample1.Value;
            sample1.SetTrimmedValue(sample2.Value);
            sample2.SetTrimmedValue(sample1Value);
        }
    }
}
